<template>
  <div>
    <employee_head username="我的销量"></employee_head>
    <ul class="list">
      <li @click="showA" :class='{select:food}'>食品仓库</li>
      <li @click="showB" :class='{select:drink}'>饮料仓库</li>
      <li @click="showC" :class='{select:livinggoods}'>日用品仓库</li>
    </ul>
    <!-- 食品仓库 -->
    <table class="table" v-show="food">
      <thead>
        <tr>
          <th>编号</th>
          <th>名称</th>
          <th>价格</th>
          <th>数量</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item,index) in list1" :key="index">
          <th>{{item.id}}</th>
          <th>{{item.name}}</th>
          <th>{{item.price}}</th>
          <th>{{item.number}}</th>
        </tr>
      </tbody>
    </table>
    <!-- 饮料仓库 -->
    <table class="table" v-show="drink">
      <thead>
        <tr>
          <th>编号</th>
          <th>名称</th>
          <th>价格</th>
          <th>数量</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item,index) in list2" :key="index">
          <th>{{item.id}}</th>
          <th>{{item.name}}</th>
          <th>{{item.price}}</th>
          <th>{{item.number}}</th>
        </tr>
      </tbody>
    </table>
    <!-- 日用品仓库 -->
    <table class="table" v-show="livinggoods">
      <thead>
        <tr>
          <th>编号</th>
          <th>名称</th>
          <th>价格</th>
          <th>数量</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item,index) in list3" :key="index">
          <th>{{item.id}}</th>
          <th>{{item.name}}</th>
          <th>{{item.price}}</th>
          <th>{{item.number}}</th>
        </tr>
      </tbody>
    </table>
    <!-- 底部 -->
    <div class="foot">
      <p>累计提成:{{sy}}</p>
    </div>
  </div>
</template>

<script>
  import employee_head from"./employee_head.vue"
  export default{
    name:"employee_mysales",
    components:{
      employee_head
    },
    data(){
      return{
        list1:[],
        list2:[],
        list3:[],
        food:true,
        drink:false,
        livinggoods:false
      }
    },
    computed:{
      sy(){
        var k=JSON.parse(window.localStorage.getItem("money")).sy
        k=Math.ceil(k)
        return k
      }
    },
    methods:{
      // 食品仓库
      showA(){
        this.food=true
        this.drink=false
        this.livinggoods=false
      },
      showB(){
        this.food=false
        this.drink=true
        this.livinggoods=false
      },
      showC(){
        this.food=false
        this.drink=false
        this.livinggoods=true
      }
    },
    mounted(){
      var obj=JSON.parse(window.localStorage.getItem("salelist"))
      this.list1=obj.saleFood
      this.list2=obj.saleDrink
      this.list3=obj.saleLivingGoods
    }
  }
</script>

<style scoped="scoped">
  ul,li,p{
    margin:0;
    padding:0;
    list-style:none;
  }
  .list{
    display:flex;
    padding-top:10px;
    padding-bottom:10px;
  }
  .list li{
    width:40%;
    text-align: center;
    line-height: 40px;
  }
  .select{
    background-color:lightpink;
    color:white;
  }
  .foot{
    position:fixed;
    width:100%;
    bottom:0;
    line-height:40px;
    border-top:1px solid lightpink;
    font-size:12px;
    text-align: center;
  }
</style>
